<?php

namespace App\Http\Controllers\API\Admin;

use App\Http\Requests\API\CreateIntegralLogAPIRequest;
use App\Http\Requests\API\UpdateIntegralLogAPIRequest;
use App\Models\IntegralLog;
use App\Repositories\IntegralLogRepository;
use App\User;
use App\ZL\Controllers\ApiBaseController;
use Illuminate\Http\Request;
use App\Http\Controllers\AppBaseController;
use Illuminate\Support\Facades\Auth;
use InfyOm\Generator\Criteria\LimitOffsetCriteria;
use Prettus\Repository\Criteria\RequestCriteria;
use Response;

/**
 * Class IntegralLogController
 * @package App\Http\Controllers\API
 */

class IntegralLogAPIAdminController extends ApiBaseController
{
    /** @var  IntegralLogRepository */
    private $integralLogRepository;
    protected $model_name = 'App\Models\IntegralLog';
    protected $model_load_array = [
    ];
    public function __construct(IntegralLogRepository $integralLogRepo)
    {
        $this->integralLogRepository = $integralLogRepo;
    }

    public function authLimit(&$model)
    {
        $shop = Auth::guard('admin')->user()->shop;
        $res =  [];

        $nickname = request('nickname');
        if($nickname){
            $user_ids = User::where('shop_id',$shop->id)->where('nickname','like',"%$nickname%")->pluck('id');
            $model = $model->whereIn('user_id', $user_ids->toArray());
        }

        $res[] = ['shop_id', '=', $shop->id];
        return $res;
    }

}
